/**
 * 上传阿里云的工具模块
 */
const OSS = require('ali-oss')
const path = require('path')

// 导入 oss 的配置文件
const osscomfig = require('../comfig/osscomfig')

// 配置客户端
const client = new OSS({
   region: osscomfig.REGION,
   accessKeyId: osscomfig.ACCESSKEYID,
   accessKeySecret: osscomfig.ACCESSKEYSECRET,
   bucket: osscomfig.BUCKET
})

// 本地上传文件到远端
function pushdata(fileName, filePath) {
   return client.put(fileName, path.normalize(filePath))
}

// 删除本地数据库对应的远端文件
function deldata(fileName) {
   return client.delete(fileName)
}

module.exports = {pushdata, deldata}